package com.xinbochuang.machine.admin.controller.scrap;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xinbochuang.machine.admin.domain.scrap.ScrapUse;
import com.xinbochuang.machine.admin.service.scrap.IScrapUseService;
import com.xinbochuang.machine.common.controller.BaseController;
import com.xinbochuang.machine.common.domain.TableDataInfo;
import com.xinbochuang.machine.framework.web.domain.AjaxResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 黄晓鹏
 * @date 2020-10-25
 */
@RestController
@RequestMapping("/scrap-use")
public class ScrapUseController extends BaseController {

    @Resource
    private IScrapUseService scrapUseService;

    /**
     * 新增利旧/报废
     */
    @PreAuthorize("@ss.hasPermi('system:scrap-use:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ScrapUse scrapUse) {
        return toAjax(scrapUseService.add(scrapUse));
    }

    /**
     * 利旧/报废分页列表
     */
    @PreAuthorize("@ss.hasPermi('system:scrap-use:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScrapUse scrapUse) {
        IPage<ScrapUse> list = scrapUseService.selectScarpUseList(scrapUse);
        return getDataTable(list);
    }

    /**
     * 状态修改
     */
    @PreAuthorize("@ss.hasPermi('system:scrap-use:check')")
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody ScrapUse scrapUse) {
        return toAjax(scrapUseService.changeStatus(scrapUse));
    }

}

